<?php
declare (strict_types=1);

namespace app\index\controller;

use app\common\model\ProductCate;
use app\common\tool\Result;
use think\facade\View;
use think\Response;

class Classify extends Base
{

    /**
     * @var int 当前分类开启的级别，1=>一级分类，2=>二级分类，最大二级
     */
    protected $grade = 2;

    public function index()
    {
        return View::fetch('', [
            'grade' => $this->grade,
            'cate'  => ProductCate::where(['status' => 1, 'pid' => 0])->select(),
        ]);
    }

    public function getCate($pid = 0)
    {
        return Result::success('success', ProductCate::getCate($pid));
    }


}

